import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Register from '../views/Register.vue'
import Home from '../views/Home.vue'
import Order from '../views/Order.vue'
import Advise from "@/views/Advise.vue";
import Random from "@/views/Random.vue";
import Personal from "@/views/Personal.vue";
import Type from "@/views/Type.vue";
import Wrong from "@/views/Wrong.vue";
import Rank from "@/views/Rank.vue";
import Collection from "@/views/Collection.vue";
import ChangePsw from "@/views/ChangePsw.vue";

const routes = [
    {
      path: '/',
      name: Login,
      component:()=>Login
    },
    {
      path: '/register',
      name: Register,
      component:() => Register
    },
    {
      path: '/home',
      name: Home,
      component:()=>Home
    },
    {
      path:'/order',
      name:'Order',
      component:()=>Order
    },
    {
      path:'/advise',
      name:'Advise',
      component:()=>Advise
    },
    {
      path:'/profile',
      name:'Profile',
      component:()=>Profile
    },
    {
      path:'/random',
      name:'Random',
      component:()=>Random
    },
    {
      path:'/personal',
      name:'Personal',
      component:()=>Personal
    },
    {
      path:'/type',
      name:'Type',
      component:()=>Type
    },
    {
        path:'/wrong',
        name:'Wrong',
        component:()=>Wrong
    },
    {
        path: '/rank',
        name: 'Rank',
        component: () => Rank
    },
    {
        path: '/collection',
        name: 'Collection',
        component: () => Collection
    },
    {
        path: '/changePsw',
        name: 'ChangePsw',
        component: () => ChangePsw
    },
    {
        path: '/admin/manage',
        redirect: '/admin/manage/questions', // 添加重定向
        component: () => import('../views/Manage_Home.vue'),
        children: [
            {
                path: 'questions',
                name: 'QuestionManage',
                component: () => import('../views/Manage_Questions.vue')
            },
            {
                path: 'majors-categories',
                name: 'MajorsCategoriesManage',
                component: () => import('../views/Manage_MajorsCategories.vue')
            },
            {
                path: 'users',
                name: 'UsersManage',
                component: () => import('../views/Manage_Users.vue')
            },
            {
                path: 'comments',
                name: 'CommentsManage',
                component: () => import('../views/Manage_Comments.vue')
            }
            // 其他子路由...
        ]
    }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router